@layout("/common/_curd/_container.html"){


<script type="text/javascript">
	var grid_selector = "#grid-table";
	var pager_selector = "#grid-pager";
	var select= 0;
	var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
	$(function(){
		
		$("#btn_close").bind("click",function(){
			parent.layer.close(index);
		});
		$("#btn_save").bind("click",function(){
		
			var ids = "";
			var names = "";
			
			var _pobj = parent.$("#${index!}").attr("name");
			if (_pobj != undefined){
				var _name = _pobj.replace("token_", "");
				parent.$("#${index!}").attr("name", _name);
				parent.$("#form_token").val(1);
			}
			
			parent.$("#${index!}_INPUT").val(names);
			parent.$("#${index!}").val(ids);
			parent.layer.close(index);
		
		});
		
		initGrid();
	});
	
	function initGrid(){
		var grid_url = "${basePath}/homecity/select";
		var _colnames = ["ID", 
						"城市名字", 
						"城市拼音",
						"是否热门"
						];
		var _colmodel = [{name:"id", index:"id", width:100},
						{name:"cityname", index:"cityname", width:100},
						{name:"citypyname", index:"citypyname", width:100},
						{name:"ishot", index:"ishot", width:100}];
		
		jQuery(grid_selector).jqGrid({
			url : grid_url,
		    shrinkToFit : true,
			colNames : _colnames,
			colModel : _colmodel, 
			jsonReader : {id :"id"},
			multiselect : false,
			pager : pager_selector,
			postData : {sort : "id", order : "desc"},
			onSelectRow: function(id){
				select = id;
			},
			ondblClickRow: function(rowid,iRow,iCol,e){
				var data = jQuery(grid_selector).jqGrid('getCell',iRow,iCol);  
				var rowDatas = $("#grid-table").jqGrid('getRowData', rowid);
				
				var _pobj = parent.$("#${index!}").attr("name");
				if (_pobj != undefined){
					var _name = _pobj.replace("token_", "");
					parent.$("#${index!}").attr("name", _name);
					parent.$("#form_token").val(1);
				}
				
				parent.$("#${index!}_INPUT").val(rowDatas.cityname);
				parent.$("#${index!}").val(rowDatas.id);
				parent.layer.close(index);
			} 
		});
	}
</script>


	<!-- 配置grid -->
	<div class="row">
		<div class="col-xs-12 tb-grid">
			<!-- 配置 查询 -->
			@ var _col=[
			@		{name:"城市名字", index:"cityname", type:"text"}
			@];
			@ include("/common/_function/_search.html",{"col":_col}){}
			<!-- 按钮 -->
			<div class="welljq well-sm" id="btns"></div>
			<!-- grid -->
			<table id="grid-table"></table>
			<!-- 分页-->
			<div id="grid-pager"></div>
		</div>
	</div>
	<!-- 引入所需的js -->
	 <script src="${basePath}/static/assets/js/jqGrid/jquery.jqGrid.src.js" type="text/javascript" ></script>
 <script src="${basePath}/static/assets/js/jqGrid/i18n/grid.locale-cn.js" type="text/javascript" ></script>
 <script src="${basePath}/static/style/js/forlist.js" type="text/javascript" ></script>
 <script src="${basePath}/static/blade/js/blade-btn.js" type="text/javascript" ></script>
 
 <script src="${basePath}/static/assets/js/jquery.contextmenu.js" type="text/javascript" ></script>
 <script src="${basePath}/static/blade/js/blade-girdmenu.js" type="text/javascript" ></script>
@}	